home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / progem.lzh / apndx5.prf < prev    next >
Encoding:
Text File  |  1987-06-23  |  5.3 KB  |  175 lines

  1. .!****************************************************************************
  2. .! 
  3. .! ANTIC PUBLISHING INC., COPYRIGHT 1985.  REPRINTED BY PERMISSION.
  4. .!
  5. .! ** Professional GEM ** by Tim Oren
  6. .!
  7. .! Proff File by ST enthusiasts at
  8. .! Case Western Reserve University
  9. .! Cleveland, Ohio
  10. .! uucp : decvax!cwruecmp!bammi
  11. .! csnet: bammi@case
  12. .! arpa : bammi%case@csnet-relay
  13. .! compuserve: 71515,155
  14. .!
  15. .!****************************************************************************
  16. .!
  17. .!            Begin Appendix 5
  18. .!
  19. .!***************************************************************************
  20. .!
  21. .!
  22. .AP V Sample Code for Part VI
  23. /* >>>>>>>>>>>>>>>>>>>>>>>>>>> MFDB Structure <<<<<<<<<<<<<<<<<<<<<<<<<< */
  24.                     /* Memory Form Definition Block */
  25. typedef struct fdbstr
  26. {
  27.     long        fd_addr;    /* Form address            */
  28.     int        fd_w;        /* Form width in pixels        */
  29.     int        fd_h;        /* Form height in pixels    */
  30.     int        fd_wdwidth;    /* Form width in memory words    */
  31.     int        fd_stand;    /* Standard form flag        */
  32.     int        fd_nplanes;    /* Number of color planes    */
  33.     int        fd_r1;        /* Dummy locations:        */
  34.     int        fd_r2;        /* Reserved for future use    */
  35.     int        fd_r3;
  36. } MFDB;
  37. .bp
  38. /* >>>>>>>>>>>>>>>>>>>> Resource Transform Utilities <<<<<<<<<<<<<<<<<< */
  39. /*------------------------------*/
  40. /*    vdi_fix            */
  41. /*------------------------------*/
  42. VOID
  43. vdi_fix(pfd, theaddr, wb, h)        /* This routine loads the MFDB */
  44.     MFDB        *pfd;        /* Input values are the MFDB's */
  45.     LONG        theaddr;    /* address, the form's address,*/
  46.     WORD        wb, h;        /* the form's width in bytes,  */
  47.     {                /* and the height in pixels    */
  48.     pfd->fww = wb >> 1;
  49.     pfd->fwp = wb << 3;
  50.     pfd->fh = h;
  51.     pfd->np = 1;            /* Monochrome assumed           */
  52.     pfd->mp = theaddr;
  53.     }
  54.  
  55. /*------------------------------*/
  56. /*    vdi_trans        */
  57. /*------------------------------*/
  58. WORD
  59. vdi_trans(saddr, swb, daddr, dwb, h)     /* Transform the standard form */
  60.     LONG        saddr;        /* pointed at by saddr and     */
  61.     UWORD        swb;        /* store in the form at daddr  */
  62.     LONG        daddr;        /* Byte widths and pixel height*/
  63.     UWORD        dwb;        /* are given               */
  64.     UWORD        h;
  65.     {
  66.     MFDB        src, dst;    /* These are on-the-fly MFDBs  */
  67.  
  68.     vdi_fix(&src, saddr, swb, h);    /* Load the source MFDB           */
  69.     src.ff = TRUE;            /* Set it's std form flag      */
  70.  
  71.     vdi_fix(&dst, daddr, dwb, h);    /* Load the destination MFDB   */
  72.     dst.ff = FALSE;            /* Clear the std flag           */
  73.     vr_trnfm(vdi_handle, &src, &dst );    /* Call the VDI           */
  74.     }
  75.  
  76. /*------------------------------*/
  77. /*    trans_bitblk        */
  78. /*------------------------------*/
  79. VOID
  80. trans_bitblk(obspec)            /* Transform the image belonging */
  81.     LONG    obspec;            /* to the bitblk pointed to by   */
  82.     {                /* obspec.  This routine may also*/
  83.     LONG    taddr;            /* be used with free images     */
  84.     WORD    wb, hl;
  85.  
  86.     if ( (taddr = LLGET(BI_PDATA(obspec))) == -1L)
  87.         return;            /* Get and validate image address */
  88.     wb = LWGET(BI_WB(obspec));    /* Extract image dimensions      */
  89.     hl = LWGET(BI_HL(obspec));
  90.     vdi_trans(taddr, wb, taddr, wb, hl);    /* Perform a transform      */
  91.     }                    /* in place          */
  92.  
  93. /*------------------------------*/
  94. /*    trans_obj        */
  95. /*------------------------------*/
  96. VOID
  97. trans_obj(tree, obj)            /* Examine the input object.  If  */
  98.     LONG    tree;            /* it is an icon or image, trans- */
  99.     WORD    obj;            /* form the associated raster      */
  100.     {                /* forms in place.          */
  101.     WORD    type, wb, hl;        /* This routine may be used with  */
  102.     LONG    taddr, obspec;        /* map_tree() to transform an     */
  103.                     /* entire resource tree          */
  104.  
  105.     type = LLOBT(LWGET(OB_TYPE(obj)));        /* Load object type */
  106.     if ( (obspec = LLGET(OB_SPEC(obj))) == -1L)    /* Load and check   */
  107.         return (TRUE);                /* ob_spec pointer  */
  108.     switch (type) {
  109.         case G_IMAGE:
  110.             trans_bitblk(obspec);        /* Transform image  */
  111.             return (TRUE);
  112.         case G_ICON:                /* Load icon size   */
  113.             hl = LWGET(IB_HICON(obspec));
  114.             wb = (LWGET(IB_WICON(obspec)) + 7) >> 3;
  115.                             /* Transform data   */
  116.             if ( (taddr = LLGET(IB_PDATA(obspec))) != -1L)
  117.                 vdi_trans(taddr, wb, taddr, wb, hl);
  118.                             /* Transform mask   */
  119.             if ( (taddr = LLGET(IB_PMASK(obspec))) != -1L)
  120.                 vdi_trans(taddr, wb, taddr, wb, hl);
  121.             return (TRUE);
  122.         default:
  123.             return (TRUE);
  124.         }
  125.     }
  126. .bp
  127. /* >>>>>>>>>>>>>>>>  Macro definitions for the code above <<<<<<<<<<<<<<< */
  128.  
  129. #define BI_PDATA(x)    (x)
  130. #define BI_WB(x)    (x + 4)
  131. #define BI_HL(x)    (x + 6)
  132. #define OB_TYPE(x)     (tree + (x) * sizeof(OBJECT) + 6)
  133. #define OB_SPEC(x)     (tree + (x) * sizeof(OBJECT) + 12)
  134. #define IB_PMASK(x)    (x)
  135. #define IB_PDATA(x)    (x + 4)
  136. #define IB_WICON(x)    (x + 22)
  137. #define IB_HICON(x)    (x + 24)
  138. .bp
  139. /* >>>>>>>>>>>>>>>>>>>>>>>> VDI Copy Mode Table <<<<<<<<<<<<<<<<<<<<<<<<< */
  140.  
  141. Symbols: N = new destination pixel value (0 or 1)
  142.      D = old destination pixel value (0 or 1)
  143.      S = source pixel value (0 or 1)
  144.      ~ = Boolean not (inversion)
  145.      & = Boolean and
  146.      | = Boolean or
  147.      ^ = Boolean xor (exclusive-or)
  148.  
  149. Mode Number    Action
  150. ----------    ------
  151.     0        N = 0        (USE V_BAR INSTEAD)
  152.     1        N = S & D
  153.     2        N = S & ~D
  154.     3        N = S        (REPLACE)
  155.     4        N = ~S & D    (ERASE)
  156.     5        N = D        (USELESS)
  157.     6        N = S ^ D    (XOR)
  158.     7        N = S | D    (TRANSPARENT)
  159.     8        N = ~ (S | D)
  160.     9        N = ~ (S ^ D)
  161.    10        N = ~D        (USE V_BAR INSTEAD)
  162.    11        N = S | ~D
  163.    12        N = ~S
  164.    13        N = ~S | D    (REVERSE TRANSPARENT)
  165.    14        N = ~ (S & D)
  166.    15        N = 1        (USE V_BAR INSTEAD)
  167.  
  168. /* >>>>>>>>>>>>>>>>>>>>>>>> END OF DOWNLOAD <<<<<<<<<<<<<<<<<<<<<<<<<< */
  169. .!
  170. .!****************************************************************************
  171. .!
  172. .!            End Appendix 5
  173. .!
  174. .!****************************************************************************
  175.